@model ContosoUniversity.Models.Instructor

@{
    ViewData["Title"] = "Create";
}

<h2>Create</h2>

<form asp-action="Create">
    <div class="form-horizontal">
        <h4>Instructor</h4>
        <hr />
        <div asp-validation-summary="ModelOnly" class="text-danger"></div>
        <div class="form-group">
            <label asp-for="LastName" class="control-label"></label>
            <input asp-for="LastName" class="form-control" />
            <span asp-validation-for="LastName" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="FirstMidName" class="control-label"></label>
            <input asp-for="FirstMidName" class="form-control" />
            <span asp-validation-for="FirstMidName" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="HireDate" class="control-label"></label>
            <input asp-for="HireDate" class="form-control" />
            <span asp-validation-for="HireDate" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="OfficeAssignment.Location" class="control-label"></label>
            <input asp-for="OfficeAssignment.Location" class="form-control" />
            <span asp-validation-for="OfficeAssignment.Location" class="text-danger" />
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <table>
                    <tr>
                        @{
                            int cnt = 0;
                            List<ContosoUniversity.Models.SchoolViewModels.AssignedCourseData> courses = ViewBag.Courses;

                            foreach (var course in courses)
                            {
                                if (cnt++ % 3 == 0)
                                {
                                    @:</tr><tr>
                                }
                                @:<td>
                                    <input type="checkbox"
                                           name="selectedCourses"
                                           value="@course.CourseID"
                                           @(Html.Raw(course.Assigned ? "checked=\"checked\"" : "")) />
                                           @course.CourseID @:  @course.Title
                                    @:</td>
                            }
                            @:</tr>
                        }
                </table>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
</form>

<div>
    <a asp-action="Index">Back to List</a>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
